#define QOS_SYS_TASKS       2   // at least one idel task & highest prio task for OS
#define QOS_MAX_TASKS       ( QOS_USER_TASKS + QOS_SYS_TASKS )

#define TASK_IDEL_PRIO      ( QOS_MAX_TASKS - 1 )
#define TASK_HIGHEST_PRIO   0
#define TASK_INVALID_PRIO   0xffff

#define TASK_STATE_DORMANT  0
#define TASK_STATE_READY    1
#define TASK_STATE_WAIT     2
#define TASK_STATE_RUN      3
#define TASK_STATE_MAX      3

#if OS_DEBUG > 0
#define qos_verify(a)  do{ if(!(a)) qos_verify_process(#a, __FILE__, __LINE__); }while(0)
#else
#define qos_verify(a)
#endif


typedef void (*task_entry_t)(void);

typedef struct os_tcb {
    int16u_t prio;          // task ID (0..65535)
                            // task ID equal task priority, 0 is the highest priority
    int8u_t state; 

    int32u_t delay_tick;    //
    task_entry_t task;
}os_tcb_t;
#define OS_TCB_DEFAULT {                    \
    TASK_INVALID_PRIO, TASK_STATE_DORMANT   \
    , 0, NULL                               \
}



// task management----------------------
void qos_task_create( int16u_t prio, const task_entry_t task );

// time management----------------------
void qos_time_delay(int16u_t ticks);
void qos_time_tick_isr(void);
void qos_sleep(int16u_t ticks);

// miscellaneous------------------------
void qos_init(void);
void qos_start(void);

#ifndef QOS_USER_TASKS
#error "os_cfg.h missing QOS_USER_TASKS: number of tasks in your application"
#endif

// no more------------------------------

